﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Camera;
using CameraFactory;//引入CameraFactory命名空间

namespace _00_反射_单相机
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        /// <summary>
        /// 设置相机参数
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button1_Click(object sender, EventArgs e)
        {
            string[] SaveInfoArray = new string[6];
            //动态链接库的位置
            SaveInfoArray[0] = this.textBox1.Text;
            //加载类的名称
            SaveInfoArray[1] = this.textBox2.Text;
            //是否立即加载
            SaveInfoArray[2] = this.radioButton1.Checked.ToString();
            //相机名称
            SaveInfoArray[3] = this.textBox3.Text;
            //图片路径
            SaveInfoArray[4] = this.textBox4.Text;
            //延时时间
            SaveInfoArray[5] = this.trackBar1.Value.ToString();

            System.IO.File.WriteAllLines("CameraInfo.txt", SaveInfoArray);
        }

        private void Form1_Shown(object sender, EventArgs e)
        {
            //判断文件是否存在
            if (System.IO.File.Exists("CameraInfo.txt"))
            {
                //读取全部的内容然后显示在控件上
                string[] ReadInfoArray = System.IO.File.ReadAllLines("CameraInfo.txt");
                this.textBox1.Text = ReadInfoArray[0];
                this.textBox2.Text = ReadInfoArray[1];
                if (Convert.ToBoolean(ReadInfoArray[2]))
                {
                    this.radioButton1.Checked = true;
                }
                else
                {
                    this.radioButton2.Checked = true;
                }
                this.textBox3.Text = ReadInfoArray[3];
                this.textBox4.Text = ReadInfoArray[4];
                this.trackBar1.Value = Convert.ToInt32(ReadInfoArray[5]);
            }
        }
        /// <summary>
        /// 设置
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button2_Click(object sender, EventArgs e)
        {
            string[] SaveInfoArray = new string[6];
            //动态链接库的位置
            SaveInfoArray[0] = this.textBox1.Text;
            //加载类的名称
            SaveInfoArray[1] = this.textBox2.Text;
            //是否立即加载
            SaveInfoArray[2] = this.radioButton1.Checked.ToString();
            //相机名称
            SaveInfoArray[3] = this.textBox3.Text;
            //图片路径
            SaveInfoArray[4] = this.textBox4.Text;
            //延时时间
            SaveInfoArray[5] = this.trackBar1.Value.ToString();

            System.IO.File.WriteAllLines("CameraInfo.txt", SaveInfoArray);


            //实例化类
            AbstractCamera camera = CameraFactory.Factory.GetCameraObj();
            //空间实例化，然后填充到容器当中
            
            

        }
    }
}
